'use strict';
const db = uniCloud.database();
const $ = db.command.aggregate; //聚合操作符
exports.main = async (event, context) => {
	const {
		userId
	} = event;

	let userInfo = await db.collection('user').doc(userId).get();
	let author_likes_ids = userInfo.data[0].author_likes_ids;
	let list = await db.collection('user')
		.aggregate()
		.addFields({
			is_follow: $.in(['$id', author_likes_ids])
		})
		.match({
			is_follow: true
		})
		.end()

	return {
		code: 0,
		msg: '获取数据成功',
		data: {
			list: list.data
		}
	}
};